package com.googlecode.maurersmarbles;

import android.graphics.Color;
import android.graphics.Point;

import com.googlecode.maurersmarbles.framework.Graphics;
import com.googlecode.maurersmarbles.framework.Graphics.ImageFormat;
import com.googlecode.maurersmarbles.framework.Image;

public class ImageBoard extends Board {
	
	String theme = "classic/";
	protected static final String FILE_NAME_BOARD = "board.png";
	protected static final String FILE_NAME_MARBLES[] = {"marble0.png", "marble1.png", "marble2.png", "marble3.png"};
	protected static final String FILE_NAME_SAFE_SPACES[] = {"safe0.png", "safe1.png", "safe2.png", "safe3.png"};
	protected static final String FILE_NAME_SPACE = "space.png";

	/**
	 * Creates a new ImageBoard.
	 * 
	 * @param startXY the x/y location of the board
	 * @param size the size of the board (width and height)
	 */
	public ImageBoard(Point startXY, int size) {
		super(startXY, size);
	}

	/**
	 * Returns the color for the given player.
	 * 
	 * @param player the player to get the color for
	 * @return the color for the given player
	 */
	protected int getPlayerColor(int player) {
		int color = Color.BLACK;
		switch (player) {
			case 0:
				color = Color.BLUE;
				break;
			case 1:
				color = Color.YELLOW;
				break;
			case 2:
				color = Color.RED;
				break;
			case 3:
				color = Color.GREEN;
				break;
		}
		return color;
	}

	@Override
	public void drawBoard(Graphics g, Point point, int size) {
		Image image = g.newImage(theme + FILE_NAME_BOARD, ImageFormat.ARGB4444);
		g.drawImage(image, point.x,point.y, size, size);
	}

	@Override
	public void drawEmptySpace(Graphics g, Point point, int size) {
		Image image = g.newImage(theme + FILE_NAME_SPACE, ImageFormat.ARGB4444);
		g.drawImage(image, point.x,point.y, size, size);
	}

	@Override
	public void drawHomeSpace(Graphics g, Point point, int size, int player) {
		drawSafeSpace(g, point, size, player);
	}

	@Override
	public void drawMarble(Graphics g, Point point, int size, int player) {
		Image image = g.newImage(theme + FILE_NAME_MARBLES[player], ImageFormat.ARGB4444);
		g.drawImage(image, point.x, point.y, size, size);
	}

	@Override
	public void drawSafeSpace(Graphics g, Point point, int size, int player) {
		Image image = g.newImage(theme + FILE_NAME_SAFE_SPACES[player], ImageFormat.ARGB4444);
		g.drawImage(image, point.x, point.y, size, size);
	}

	@Override
	public void drawStartSpace(Graphics g, Point point, int size, int player) {
		drawSafeSpace(g, point, size, player);
	}

}
